package com.duowei.diandan.bean.food;

import com.duowei.diandan.db.entry.Tcsd;

import java.util.List;

/**
 * 套餐已选择项
 */
public class MealChildChecked {
    private List<String> cateList;
    private Tcsd tcsd;
    private boolean singleChoice;

    public MealChildChecked(List<String> cateList, Tcsd tcsd, boolean singleChoice) {
        this.cateList = cateList;
        this.tcsd = tcsd;
        this.singleChoice = singleChoice;
    }

    public List<String> getCateList() {
        return cateList;
    }

    public void setCateList(List<String> cateList) {
        this.cateList = cateList;
    }

    public Tcsd getTcsd() {
        return tcsd;
    }

    public void setTcsd(Tcsd tcsd) {
        this.tcsd = tcsd;

        if (mOnDataChangedListener != null) {
            mOnDataChangedListener.onDataChanged();
        }
    }

    public String getCateStr() {
        StringBuilder sb = new StringBuilder();
        for (String c : cateList) {
            if (sb.length() == 0) {
                sb.append(c);
            } else {
                sb.append("、").append(c);
            }
        }

        return sb.toString();
    }

    public boolean isSingleChoice() {
        return singleChoice;
    }

    private OnDataChangedListener mOnDataChangedListener;

    public void setOnDataChangedListener(OnDataChangedListener onDataChangedListener) {
        mOnDataChangedListener = onDataChangedListener;
    }

    public interface OnDataChangedListener {
        void onDataChanged();
    }
}
